/**
 *
 */
Ext.define('vacake.view.More', {
    extend: 'Ext.Container',
    xtype: 'moreView',
    config: {
        layout: 'vbox',
        scrollable:true, 
        items: [
            {
                docked: 'top',
                xtype: 'titlebar',
                title: '更多'
            },
            {
                xtype: 'panel',
                cls: 'x-area1',
               // style:'padding:10px;',
                items: {
                    xtype: 'label',
                    cls:'font2 color2 height30 paddingtop5',
                    html: '<span class="paddinglfet10"><div style="float: left;margin-right: -10px;margin-left: 10px;margin-top: -2px;"><img src="resources/images/more_7.png"  height="20px" style=" vertical-align: middle"/></div>分 享 至</span>',
                    listeners: {
                        painted: function (label) {
                            label.on('tap', function () {
                                cordova.exec(function (winParam) {
                                    },
                                    function (error) {
                                    },
                                    "Share",
                                    "share",
                                    ["维也纳的app应用上线了 下载:http://www.xayoudao.com/viennacake/", "http://www.xayoudao.com/viennacake/logo.png","http://www.xayoudao.com/viennacake/"]);
                                return false;
                            }, this);
                        }
                    }
                }
            },
            {
                xtype: 'panel',
                cls: 'x-area1',
               // style:'padding:10px;',
                items: {
                    xtype: 'label',
                    cls:'font2 color2 height30 paddingtop5',
                    html: '<span class="paddinglfet10"><div style="float: left;margin-right: -10px;margin-left: 10px;margin-top: -2px;"><img src="resources/images/more_8.png"  height="20px" style=" vertical-align: middle"/></div>一键呼叫</span>',
                    listeners: {
                        painted: function (label) {
                            label.on('tap', function () {
                                Ext.Viewport.mask({xtype: 'loadmask', message: '加载数据中...'  });
                                Ext.Viewport.animateActiveItem('keyCall', {type: 'slide', direction: 'left'});
                                return false;
                            }, this);
                        }
                    }
                }
            },
            {
                xtype: 'panel',
                cls: 'x-area1',
                //style:'padding:10px;',
                items: [
                    {
                        xtype: 'label',
                        cls:'more_border font2 color2 height40 ',
                        html: '<span class="paddinglfet10"><div style="float: left;margin-right: -10px;margin-left: 10px;margin-top: -2px;"><img src="resources/images/more_4.png"  height="20px" style=" vertical-align: middle"/></div>温馨提示</span>',
                        listeners: {
                            painted: function (label) {
                                label.on('tap', function () {
                                    window.localStorage.setItem('more_caid', '28');
                                    Ext.Viewport.animateActiveItem('moreInfo', {type: 'slide', direction: 'left'});
                                    return false;
                                }, this);
                            }
                        }
                    },
//                    {
//                        xtype: 'label',
//                        html: '意见反馈',
//                        listeners: {
//                            painted: function (label) {
//                                label.on('tap', function () {
//
//                                }, this);
//                            }
//                        }
//                    },
                    {
                        xtype: 'label',
                        cls:'font2 color2 height40 paddingtop5',
                        html: '<span class="paddinglfet10"><div style="float: left;margin-right: -10px;margin-left: 10px;margin-top: -2px;"><img src="resources/images/more_1.png"  height="20px" style=" vertical-align: middle"/></div>关于</span>',
                        listeners: {
                            painted: function (label) {
                                label.on('tap', function () {
                                    window.localStorage.setItem('more_caid', '29');
                                    Ext.Viewport.animateActiveItem('moreInfo', {type: 'slide', direction: 'left'});
                                    return false;
                                }, this);
                            }
                        }
                    }
                ]
            },
            {
                xtype: 'panel',
                cls: 'x-area1',
                //style:'padding:10px;',
                items: [
                    {
                        xtype: 'label',
                        cls:' font2 color2 height40 ',
                        html: '<span class="paddinglfet10"><div style="float: left;margin-right: -10px;margin-left: 10px;margin-top: -2px;"><img src="resources/images/more_10.png"  height="20px" style=" vertical-align: middle"/></div>关于本软件</span>',
                        listeners: {
                            painted: function (label) {
                                label.on('tap', function () {
                                    window.localStorage.setItem('more_caid', '30');
                                    Ext.Viewport.animateActiveItem('moreInfo', {type: 'slide', direction: 'left'});
                                    return false;
                                }, this);
                            }
                        }
                    }
                ]
            },
            {
                xtype: 'panel',
                style:'padding:10px;',
                items: [
                    {
                        xtype: 'button',
                        ui: 'confirm',
                        cls: 'x-button2',
                        style:'margin:0 5px 10px 5px;',
                        text: '更新',
                        handler: function () {
                            cordova.exec(function (message) {
                                },
                                function (error) {
                                },
                                "CheckVersion",
                                "checkVersion",
                                [Ext.getCmp('hidden_appStoreId').getValue()]);
                        }
                    },
                    {
                        xtype: 'hiddenfield',
                        name: 'appStoreId',
                        id: 'hidden_appStoreId',
                        value: '123456789'
                    },
                    {
                        xtype: 'button',
                        ui: 'confirm',
                        style:'margin:0 5px;',
                        id: 'logout',
                        text: '退出登录',
                        hidden: true,
                        handler: function () {
                            Ext.Msg.confirm('是否退出', '', function (data) {
                                if (data == 'yes') {
                                    Ext.Viewport.mask({
                                        xtype: 'loadmask',
                                        message: '登出中...'
                                    });
                                    Ext.Ajax.request({
                                        url: Global.api_url + '/cloud/1/users_logout',
                                        method: 'POST',
                                        scope: this,
                                        success: function (response) {
                                            Ext.Viewport.unmask();
                                            var returnText = Ext.decode(response.responseText);
                                            cordova.exec(function(message){}, function(error){}, "Messages", "showMsg", [returnText.Variables.Message.messagestr]);
//                                            Ext.Msg.alert(returnText.Variables.Message.messagestr);
                                            if (returnText.Variables.Result.code == 0) {
                                                window.localStorage.removeItem('app_Login_id');
                                                window.localStorage.removeItem('app_Login_name');
                                                window.localStorage.removeItem('app_Login_avatar');
                                                this.setHidden(true);
                                            }
                                        },
                                        failure: function () {//请求失败时执行操作
                                            Ext.Viewport.unmask();
//                                            Ext.Msg.alert('请求失败', '服务器维护中....');
                                            cordova.exec(function(message){}, function(error){}, "Messages", "showMsg", ['请求失败,服务器维护中...']);
                                        }
                                    })
                                }
                            }, this);
                        }
                    }
                ]
            }
        ],
        listeners: {
            initialize: function () {
                if(window.localStorage.getItem('appStoreId')==null){
                    Ext.Ajax.request({
                        url: Global.api_url + '/cloud/1/app_storeId_get',
                        method: 'POST',
                        params: { caid: Global.app_id},
                    scope: this,
                    success: function (response) {
                        var returnText = Ext.decode(response.responseText);
                        if (returnText.Variables.Result.code == 0 && returnText.Variables.data != null) {
                            window.localStorage.setItem('appStoreId',returnText.Variables.data);
                            Ext.getCmp('hidden_appStoreId').setValue(returnText.Variables.data);
                        }
                    }
                })
                }else{
                    Ext.getCmp('hidden_appStoreId').setValue(window.localStorage.getItem('appStoreId'));
                }
            },
            painted: function () {
                  if (window.localStorage.getItem('app_Login_id') != null) {
                    Ext.getCmp('logout').setHidden(false);
                }
              
                Ext.Viewport.unmask();
            }
        }
    }

});

